#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define HAAB    365
#define TZOLKIN 260
#define MAXDATE 15

typedef struct tag_Haab_date
{
    int Haab_day;
    char Haab_month[MAXDATE];
    int Haab_year;
} HAAB_DATE;

typedef struct tag_Tzolkin_date
{
    int Tzolkin_day_num;
    char Tzolkin_day_nam[MAXDATE];
    int Tzolkin_year;
} TZOLKIN_DATE;

//char haab_dic[][] =
//{
//   'pop', 'no', 'zip', 'zotz', 'tzec', 'xul', 'yoxkin', 'mol',
//   'chen' , 'yax', 'zac', 'ceh', 'mac', 'kankin', 'muan', 'pax', 'koyab', 'cumhu'
//}
void  process(HAAB_DATE* haab_date, TZOLKIN_DATE* Tzolkin_date)
{
    int count_day;

    if(strcmp(haab_date->Haab_month, "pop") == 0)
        count_day = haab_date->Haab_day + 0 * 20 ;
    if(strcmp(haab_date->Haab_month, "no") == 0)
        count_day = haab_date->Haab_day + 1 * 20 ;
    if(strcmp(haab_date->Haab_month, "zip") == 0)
        count_day = haab_date->Haab_day + 2 * 20 ;
    if(strcmp(haab_date->Haab_month, "zotz") == 0)
        count_day = haab_date->Haab_day + 3 * 20 ;
    if(strcmp(haab_date->Haab_month, "tzec") == 0)
        count_day = haab_date->Haab_day + 4 * 20 ;
    if(strcmp(haab_date->Haab_month, "xul") == 0)
        count_day = haab_date->Haab_day + 5 * 20 ;
    if(strcmp(haab_date->Haab_month, "yoxkin") == 0)
        count_day = haab_date->Haab_day + 6 * 20 ;

    if(strcmp(haab_date->Haab_month, "mol") == 0)
        count_day = haab_date->Haab_day + 7 * 20 ;
    if(strcmp(haab_date->Haab_month, "chen") == 0)
        count_day = haab_date->Haab_day + 8 * 20 ;
    if(strcmp(haab_date->Haab_month, "yax") == 0)
        count_day = haab_date->Haab_day + 9 * 20 ;
    if(strcmp(haab_date->Haab_month, "zac") == 0)
        count_day = haab_date->Haab_day + 10 * 20 ;
    if(strcmp(haab_date->Haab_month, "ceh") == 0)
        count_day = haab_date->Haab_day + 11 * 20 ;
    if(strcmp(haab_date->Haab_month, "mac") == 0)
        count_day = haab_date->Haab_day + 12 * 20 ;
    if(strcmp(haab_date->Haab_month, "kankin") == 0)
        count_day = haab_date->Haab_day + 13 * 20 ;
    if(strcmp(haab_date->Haab_month, "muan") == 0)
        count_day = haab_date->Haab_day + 14 * 20 ;
    if(strcmp(haab_date->Haab_month, "pax") == 0)
        count_day = haab_date->Haab_day + 15 * 20 ;
    if(strcmp(haab_date->Haab_month, "koyab") == 0)
        count_day = haab_date->Haab_day + 16 * 20 ;
    if(strcmp(haab_date->Haab_month, "cumhu") == 0)
        count_day = haab_date->Haab_day + 17 * 20;
    if(strcmp(haab_date->Haab_month, "uayet") == 0)
        count_day = haab_date->Haab_day + 18 * 20 ;
    count_day += haab_date->Haab_year * HAAB;

    //得到Tzolkin年份
    Tzolkin_date->Tzolkin_year = count_day / TZOLKIN;
    //得到月分名称
    switch(count_day % 20)
    {
        //imix, ik, akbal, kan, chicchan, cimi, manik,
        //lamat, muluk, ok, chuen, eb, ben, ix, mem, cib,
        //caban, eznab, canac, ahau
    case 0:
        strcpy(Tzolkin_date->Tzolkin_day_nam,"imix");
        break;
    case 1:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "ik");
        break;
    case 2:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "akbal");
        break;
    case 3:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "kan");
        break;
    case 4:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "chicchan");
        break;
    case 5:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "cimi");
        break;
    case 6:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "manik");
        break;
    case 7:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "lamat");
        break;
    case 8:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "muluk");
        break;
    case 9:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "ok");
        break;
    case 10:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "chuen");
        break;
    case 11:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "eb");
        break;
    case 12:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "ben");
        break;
    case 13:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "ix");
        break;
    case 14:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "mem");
        break;
    case 15:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "cib");
        break;
    case 16:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "caban");
        break;
    case 17:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "eznab");
        break;
    case 18:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "canac");
        break;
    case 19:
        strcpy(Tzolkin_date->Tzolkin_day_nam, "ahau");
        break;
    }
    Tzolkin_date->Tzolkin_day_num = count_day % 13 + 1;

}
int main()
{
    int n = 0, i = 0;
    HAAB_DATE haab;
    TZOLKIN_DATE* tzp = NULL;

    //输入数据
    scanf("%d", &n);

    tzp = (TZOLKIN_DATE*)malloc(n * sizeof(TZOLKIN_DATE));

    for(i = 0; i < n; i++)
    {
        scanf("%d. %s %d", &haab.Haab_day, haab.Haab_month, &haab.Haab_year);

        process(&haab, &tzp[i]);

    }
    printf("%d\r\n", n);
    for(i = 0; i < n; i++)
    {
        printf("%d %s %d\r\n", tzp[i].Tzolkin_day_num, tzp[i].Tzolkin_day_nam, tzp[i].Tzolkin_year);

    }

    return 0;
}
